package com.ricchieri.dao;

import java.util.List;

import org.hibernate.Criteria;
import org.springframework.cache.annotation.Cacheable;

import com.ricchieri.dao.interf.IReservationTypeDao;
import com.ricchieri.filter.BasicFilter;
import com.ricchieri.model.ReservationType;

public class ReservationTypeDao extends GenericDao implements IReservationTypeDao {
	private static final long serialVersionUID = 895803046916188759L;

	@Override
	@Cacheable(value="reservationType")
	@SuppressWarnings("unchecked")
	public List<ReservationType> getAllReservationTypes(BasicFilter filter) {
		Criteria criteria = criteriaAllReservationType(filter);
		
		return criteria.list();
	}

	@Override
	public ReservationType getReservationTypeById(
			BasicFilter reservationTypeFilter) {
		Criteria criteria = criteriaAllReservationType(reservationTypeFilter);
		
		return (ReservationType) criteria.list().get(0);
	}
	private Criteria criteriaAllReservationType(BasicFilter reservationType) {
		return super.criteriaAllBasic(reservationType, ReservationType.class);
	}

	@Override
	protected String getTableName() {
		return "reservationType";
	}	
}
